package com.sc;

import com.sc.method.DefaultInterface;
import org.junit.Test;

/**
 * Created by Shen Chao on 2018-06-06-006.
 */
public class StringTest {
    @Test
    public void strTest() {
        String s1 = "hello";
        String s2 = "he" + new String("llo");
        String s3 = "hello";

        System.out.println(s1 == s2);
        System.out.println(s1 == s3);
        System.out.println(s2 == s3);
        System.out.println(s1.equals(s2));
        System.out.println(s2.equals(s3));
    }

    @Test
    public void stringTest() {
        String s1 = "hello";
        String s2 = modify(s1);
        System.out.println(s1);
        System.out.println(s2);
    }

    public String modify(String s) {
        String s1 = s;
        System.out.println(s1 == s);
        s += " world";
        System.out.println(s1 == s);
        System.out.println(s1);
        System.out.println(s);
        return s;
    }

    @Test
    public void tes() {
//        DefaultInterface defaultInterface = new DefaultInterface() {
//            @Override
//            public String defaultStr() {
//                return "1";
//            }
//        };

        System.out.println(new DefaultInterface(){}.defaultStr());

        System.out.println(DefaultInterface.defaultString());
    }
}
